package com.king.base;

import com.google.common.base.Joiner;
import com.google.common.primitives.Ints;
import com.king.print.Printer;

/**
 * @author taomk
 * @version 1.0
 * @since 15-1-25 下午10:15
 */
public class JoinerTest {

	public static void main(String [] args) {

		// Guava中Joiner的用法
		int [] numbers = {1,2,3,4,5,6};
		System.out.println(Joiner.on(";").join(Ints.asList(numbers)));
		System.out.println(Ints.join(";", numbers));// 另一中写法

		String[] arr = new String[]{"hello", "world", "please go"};
		Printer.print(Joiner.on(",").join(arr));

		// Joiner is configurable as follows
		arr = new String[]{"hello", "world", null, "please go"};
		Printer.print(Joiner.on(",").skipNulls().join(arr));
		Printer.print(Joiner.on(",").useForNull("[null]").join(arr));
	}
}
